<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>列表过渡</title>
  <script src="./js/vue2.js"></script>
  <style>
    .v-enter,
    .v-leave-to{
      opacity: 0;
    }
    .v-enter-active,
    .v-leave-active{
      transition: opacity 1s;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- transition-group实际上会为每一个div添加transition -->
    <transition-group>
        <div v-for="(item, index) in list" :key="item.id">{{item.title}}</div>
    </transition-group>
    <button @click="handleClick">add</button>
  </div>
</body>
</html>
<script>
  var app = new Vue({
    el:'#app',
    data:{
      list:[],
      count:0,
    },
    methods:{
      handleClick: function(){
        this.list.push({
          id:this.count++,
          title:'hello world'+this.count,
        });
      }
    }
  });
</script>